from google.appengine.api import memcache
from google.appengine.api import users
from django.http import *
from ytbase.helper import *

@delete_all_cache
def flush_all(request):
    return HttpResponse('Done!')

def login(request):
    return HttpResponseRedirect(users.create_login_url('/'))

def logout(request):
    return HttpResponseRedirect(users.create_logout_url('/'))

def show(request, key):
    namespace = request.GET.get('namespace', None)
    cache = memcache.get(key, namespace=namespace)
    if cache:
        return HttpResponse(str(cache))
    else:
        return HttpResponse('Not Exists')

def delete(request, key):
    namespace = request.GET.get('namespace', None)
    memcache.delete(key, namespace=namespace)
    return HttpResponse('Done!')
